package me.zingon.demo.controller;

import me.zingon.core.context.annotation.*;
import me.zingon.demo.component.TestBean03;
import me.zingon.demo.mapper.TestMapper;
import me.zingon.demo.model.Test;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.ws.Action;
import java.io.IOException;
import java.math.BigDecimal;

@SController
@SRequestMapping("/test")
public class TestController {

    @SAutowired
    TestBean03 testBean03;

    @SAutowired
    TestMapper testMapper;

    @SRequestMapping("/m1")
    public void m1(@SRequestParam(value = "a",defaultValue = "0") Integer integer, String b, Double c, BigDecimal d, String e, HttpServletResponse response, HttpServletRequest request) throws IOException {
        System.out.println(integer);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(request.getPathInfo());
        response.getWriter().write(request.getPathInfo());
        //return "i'm m1-"+integer+testBean03;
    }

    @SRequestMapping("/m2")
    public Object m2(@SRequestBody Test t,Integer id) throws IOException {
        System.out.println(id);
        System.out.println(t);
        return testMapper.ami(2,20);
    }

    @SRequestMapping("/m3")
    public Object m3(Integer id,Integer score) throws IOException {
        System.out.println(id);
        System.out.println(score);
        return testMapper.ami(id,score);
    }

    @SRequestMapping("/m4")
    public Object m4() throws IOException {
        return testMapper.a();
    }
}
